//
//  MainViewController.m
//  UI11_1_TabelViewCell_Model类_混合Cell
//
//  Created by Scott on 15/5/22.
//  Copyright (c) 2015年 www.lanou3g.com 蓝欧3G. All rights reserved.
//

#import "MainViewController.h"
#import "FirstCell.h"
#import "ScondCell.h"

@interface MainViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, retain) UITableView *tableview;
@property (nonatomic, retain) NSMutableArray *arr;


@end

@implementation MainViewController

- (void)dealloc
{
    [_arr release];
    [_tableview release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self handleData];
    [self tableviewSubview];
    
    
}

#pragma mark - HandleData
- (void)handleData
{
    
    self.arr = @[
                 @"大连",
                 @"沈阳",
                 @"吉林"
                 ].mutableCopy;
}


#pragma mark - TableView
- (void)tableviewSubview
{
    self.tableview = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
    
    [self.view addSubview:self.tableview];
    [_tableview release];
    self.tableview.dataSource = self;
    self.tableview.delegate = self;
    
    /* 提前注册一个Cell类, 放在定义的池中 */
    [self.tableview registerClass:[FirstCell class] forCellReuseIdentifier:@"cell1"];
    [self.tableview registerClass:[ScondCell class] forCellReuseIdentifier:@"cell2"];
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.arr.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{


   
    if (indexPath.row == 0) {
        FirstCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
        
        cell.leftLabel.text = [self.arr objectAtIndex:indexPath.row];
        return cell;
        
    } else {
        
        ScondCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell2"];
        cell.rightLabel.text = [self.arr objectAtIndex:indexPath.row];
        
        return cell;
    }
    
}






#pragma mark -
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
